function y=foc_free_childcare(x)
    
% variables to be used in 'distance.m' and 'evaluate.m'
    global rho gma delta1 delta2 beta T ...
        psi_m psi_f alpha ...
        level_model level_data share_model share_data ...
        ind11 ind12 ind21 ind22 ...
        Cobb_Douglas price_reduction decomposition ...
        a_m a_f a_g a_y a_h ...
        W W_m W_f p P_c ...
        age married insample_data nkid X_theta phi_theta ...
        free_childcare no_response W0 min_Y_c outcome doutcome min_x max_x pbar_h N ...
        insample_baseline K edu_m i
        
    if (Cobb_Douglas)
        E=pbar_h(i)*(x/(min_Y_c(i)^(a_y(i))))^(1/(1-a_y(i)));        
        dE=pbar_h(i)*(1/(1-a_y(i)))*(x/(min_Y_c(i)^(a_y(i))))^(1/(1-a_y(i))-1)/(min_Y_c(i)^(a_y(i)));
    else
        E=pbar_h(i)*((x^gma-a_y(i)*min_Y_c(i)^gma)/a_h(i))^(1/gma);
        dE=pbar_h(i)*(1/gma)*((x^gma-a_y(i)*min_Y_c(i)^gma)/a_h(i))^(1/gma-1)*gma*x^(gma-1)/a_h(i);
    end
    
    % notice that we need to subtract P_c*min_Y_c because it's been added to the full income
    y=dE*x-K(i)/(1+psi_m(i)+psi_f(i))*(W0(i)-E);
    
end